#include "stdafx.h"
#include "Bank.h"


Bank::Pair::Pair( const std::tstring& cstrFrom, const std::tstring& cstrTo )
	: pair( cstrFrom, cstrTo )
{}


Bank::Pair::operator size_t() const
{
	return 0;
}


ExpressionSp Bank::Reduce( const Expression& cExpression, const std::tstring& cstrCurrency ) const
{
	return cExpression.Reduce( *this, cstrCurrency );
}


void Bank::AddRate( const std::tstring& cstrFrom, const std::tstring& cstrTo, int iRate )
{
	m_mRates[Pair( cstrFrom, cstrTo )] = iRate;
}


int Bank::FindRate( const std::tstring& cstrFrom, const std::tstring& cstrTo ) const
{
	if( cstrFrom == cstrTo )
		return 1;

	const auto citrRate( m_mRates.find( Pair( cstrFrom, cstrTo ) ) );
	return citrRate->second;
}
